<template>
	<view>
		<remind-carinfo :dataBean="dataBean"></remind-carinfo>

		<view class="item">

			<view style="display: inline-flex; height: 80rpx; justify-content: space-between; margin: 0 20rpx;">
				<u-icon name="order" color="#1573FF" label="保养信息" label-color="#333333" :customStyle="{'line-height': '80rpx',}">
				</u-icon>

				<text style="line-height: 80rpx; color: #E93131;">{{dataBean.maintenance.prompt|filterNull}}</text>
			</view>


			<u-line color="#efefef" :customStyle="{'margin-bottom': '30rpx','display': 'block',}"></u-line>

			<view v-if="dataBean.maintenance.prompt==null || dataBean.maintenance.prompt.indexOf('暂无保养') == -1">
				<view class="text-line">
					<text class="text-name">服务站名称:</text>
					<text class="text-value">{{dataBean.maintenance.serviceSite|filterNull}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">当前公里数:</text>
					<text class="text-value">{{(dataBean.maintenance.currentMile|filterNull)+"/km"}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">下次保养里程数:</text>
					<text class="text-value">{{(dataBean.maintenance.nextMile|filterNull)+"/km"}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">下次保养时间:</text>
					<text class="text-value">{{dataBean.maintenance.nextDate|filterNull}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">本次保养时间:</text>
					<text class="text-value">{{dataBean.maintenance.maintenanceDate|filterNull}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">合计费用/元:</text>
					<text class="text-value">{{dataBean.maintenance.maintenanceFee|filterNull}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">保养项目/保养金额:</text>
					<text class="text-value">{{dataBean.maintenance.maintenanceItem|filterNull}}</text>
				</view>

				<view class="text-line">
					<text class="text-name">备注:</text>
					<text class="text-value">{{dataBean.maintenance.maintenanceRemark|filterNull}}</text>
				</view>

				<picPdf :attachment="dataBean.maintenance.attachment"></picPdf>
			</view>
			
			<no-data v-else content="暂无保养~"></no-data>

			<u-line color="#efefef" border-style="dashed" :customStyle="{'display': 'block',}">
			</u-line>

			<view class="btn-detail" @click="goAddMaintain">
				保 养
			</view>

		</view>
	</view>
</template>

<script>
	import remindCarinfo from '../../components/remind-carinfo.vue';
	import picPdf from '@/components/pic-pdf.vue';

	export default {
		components: {
			remindCarinfo,
			picPdf
		},

		data() {
			return {
				dataBean: {
					maintenance:{},
					vehicle:{},
					orderCar:{}
				},
				carId: '',
				maintenanceId: '',
			}
		},
		methods: {
			goAddMaintain() {
				uni.navigateTo({
					url: './addmaintain?carId=' + this.carId + "&maintenanceId=" + this.maintenanceId,
				})
			},
			
			getData(){
				this.$u.api.maintenanceDetail({
					carId: this.carId,
					// componentId: op.maintenanceId >= 0 ? op.maintenanceId : null
				}).then(
					res => {
						this.dataBean = res;
					}
				
				);
			}
			
		},

		onLoad(op) {
			this.carId = op.carId;
			this.maintenanceId = op.maintenanceId;
			
			uni.$on('addmaintain', res=>{
				this.getData()
			})

			this.getData()
		}
	}
</script>

<style lang="scss">
	.btn-detail {
		width: 180rpx;
		height: 60rpx;
		border-radius: 50rpx;
		color: white;
		text-align: center;
		background-color: $blue15;
		font-size: 26rpx;
		line-height: 60rpx;
		align-self: flex-end;
		margin: 10rpx 20rpx 10rpx;
	}

	.nodata {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		image {
			width: 200rpx;
			height: 100rpx;
		}

		text {
			margin-top: 35rpx;
			margin-bottom: 60rpx;
			font-size: 24rpx;
			color: #C5D3E8;
		}
	}
</style>
